/*
 * math.c
 * Copyright (c) 2010 Peter Polacik <polacik.p@gmail.com>
 *
 * This file is part of AIC Library
 *
 * Licensed under MIT License, see LICENSE for more information.
 */

#include <libaic.h>
#include <math.h>
#include <aicmath.h>

double power(double base, int exp)
{
	int i;
	long double ret = 1;
	if (exp > 0) {
		for (i = 0; i < exp; i++)
			ret *= base;
	} else if (exp < 0) {
		for (i = 0; i > exp; i--)
			ret /= base;
	} else if (exp == 0)
		ret = 1;
	return ret;
}

long factorial(unsigned int n)
{
	int i, ret = 1;
	if (n == 0) return -1;
	else {
		for (i = 1; i < (n+1); i++)
			ret *= i;
	}
	return ret;
}
